#include<bits/stdc++.h>
using namespace std;
#define MAXN 100010
#define pint pair<int,int>
#define fir first
#define sec second
const double eps=1e-9;
int t,n,m,L,V,d[MAXN],v[MAXN],a[MAXN],p[MAXN],l[MAXN],dp[MAXN];
pint th[MAXN];
bool vh[MAXN];
vector<int>spt[MAXN];
template<typename T>
inline void read(T &num){
	num=0;short flag=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') ch=getchar(),flag=-1;
	while(isdigit(ch)) num=num*10+ch-'0',ch=getchar();
	num*=flag;
}inline bool subtaskAB(){
	for(int i=1;i<=n;++i)if(a[i]<0) return false;
	return true;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	read(t);
	while(t--){
		read(n),read(m),read(L),read(V);
		for(int i=1;i<=n;++i) read(d[i]),read(v[i]),read(a[i]);
		for(int i=1;i<=m;++i) read(p[i]);
		if(subtaskAB()){
			int ans=0;
			for(int i=1;i<=n;++i)
				if(d[i]<=p[m]&&sqrt(2*a[i]*(p[m]-d[i])+v[i]*v[i])-eps>V) ++ans;
			cout<<ans<<" "<<(!ans?m:m-1)<<endl;
		}else{
			for(int i=1;i<=n;++i){
				if(d[i]>p[m]){vh[i]=false;continue;}
				if(a[i]>=0) vh[i]=(sqrt(2*a[i]*(p[m]-d[i])+v[i]*v[i])-eps>V);
				else{
					if(v[i]<=V){vh[i]=false;continue;}
					int pos=lower_bound(p+1,p+1+m,d[i])-p;
					vh[i]=(sqrt(2*a[i]*(p[pos]-d[i])+v[i]*v[i])-eps>V);
					if(vh[i]) th[i].fir=pos;
				}
			}int ans1=0;for(int i=1;i<=n;++i) ans1+=vh[i];cout<<ans1<<" ";
			if(ans1==0){cout<<m<<endl;continue;}
			for(int i=1;i<=n;++i)if(vh[i]){
				if(a[i]>=0){
					if(v[i]>=V) th[i].fir=lower_bound(p+1,p+1+m,d[i])-p;
					else th[i].fir=lower_bound(p+1,p+1+m,d[i]+(V*V-v[i]*v[i])/double(2*a[i])-eps)-p;
					th[i].sec=m;
				}else th[i].sec=upper_bound(p+1,p+1+m,d[i]+(v[i]*v[i]-V*V)/double(2*-a[i])+eps)-p-1;
			}for(int i=1;i<=m;++i) spt[i].clear();
			for(int i=1;i<=n;++i)if(vh[i]) spt[th[i].sec].push_back(th[i].fir);
			set<int>jev;
			for(int i=1;i<=m;++i){
				l[i]=0;
				for(int k=0;k<spt[i-1].size();++k) jev.insert(spt[i-1][k]);
				if(!jev.empty()) l[i]=*--jev.end();
			}int maxx=0;
			for(int i=1;i<=n;++i)if(vh[i]) maxx=max(maxx,th[i].fir);
			dp[0]=0;
			for(int i=1;i<=m;++i) dp[i]=dp[l[i]]+1;
			cout<<m-dp[maxx]<<endl;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}